package dormitory;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

import org.rex.DB;
import org.rex.RMap;
import org.rex.db.Ps;
import org.rex.db.exception.DBException;

public class RexTest {
	private int id;
    private String name;
    private Date createTime;

    public RexTest() {
    }    

    public RexTest(int id, String name, Date createTime) {
        this.id = id;
        this.name = name;
        this.createTime = createTime;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public static void main(String[] args) throws DBException{
//    	String sql = "CREATE TABLE REX_TEST (ID int(11) NOT NULL, NAME varchar(30) NOT NULL, CREATE_TIME time NOT NULL)";
//        DB.update(sql);
//        System.out.println("table created.");
//        String sql1 = "INSERT INTO REX_TEST(ID, NAME, CREATE_TIME) VALUES (?, ?, ?)";
//        int i = DB.update(sql1, new Object[]{1, "test", new Date()});
//        System.out.println( i + " row inserted.");
//    	String sql = "INSERT INTO REX_TEST(ID, NAME, CREATE_TIME) VALUES (#{id}, #{name}, #{createTime})";
//    	RexTest rexTest = new RexTest(1, "test", new Date());
//
//    	int i = DB.update(sql, rexTest);
    	String sql = "SELECT * FROM REX_TEST WHERE ID = #{id} and NAME = #{name}";
    	Scanner in=new Scanner(System.in);
    	RexTest rexTest = new RexTest();
    	rexTest.setId(in.nextInt());
    	rexTest.setName(in.next());
    	List<RMap> list = DB.getMapList(sql,rexTest);
    	rexTest = DB.get(sql, rexTest, RexTest.class);
//    	rexTest=(RexTest) list;
//    	System.out.println(rexTest.id +rexTest.name +rexTest.createTime);
	}
}
